/*
* File: 		main.c
* Author: 		Akira
* Date: 		2023-11-16
* Description:  TODO
* Version: 		1.0.0
* Modify: 		None.
*/

#include <stdio.h>

#define USE_RING_QUEUE	1
#define USE_QUEUE		0
#define USE_STACK		0

#if USE_RING_QUEUE
#include "ring_queue.h"
#endif
#if USE_QUEUE
#include "queue.h"
#endif
#if USE_STACK
#include "stack.h"
#endif

int main()
{
	//TODO
	ElemType DataBuffer[12] = {1,2,4,8,16,32,64,128,256,512,1024,2048};
	ElemType data;
#if USE_RING_QUEUE
	printf("ring_queue test begin\n");
	LinkRingQueue RingQueue;
	ElemType RingLeadData;
	InitRingQueue(&RingQueue);
	for(int i = 0; i < sizeof(DataBuffer) / sizeof(DataBuffer[0]); i++)
	{
		EnRingQueue(&RingQueue, DataBuffer[i]);
	}
	while(!RingQueueEmpty(&RingQueue))
	{
		GetRingLead(&RingQueue, &RingLeadData);
		DeRingQueue(&RingQueue, &data);
		printf("%4d,%4d,%4d\n", data, RingLeadData, LengthRingQueue(&RingQueue));
	}
	printf("\n");
	printf("ring_queue test end\n");
#endif

#if USE_QUEUE
	printf("queue test begin\n");
	LinkQueue Queue;
	ElemType LeadData;
	InitQueue(&Queue);
	for(int i = 0; i < sizeof(DataBuffer) / sizeof(DataBuffer[0]); i++)
	{
		EnQueue(&Queue, DataBuffer[i]);
	}
	while(!IsEmpty(&Queue)) 
	{
		GetLead(&Queue, &LeadData);
		DeQueue(&Queue, &data);
		printf("%4d,%4d,%4d\n", data, LeadData, LengthQueue(&Queue));
	}
	printf("\n");
	printf("queue test end\n");
#endif

#if USE_STACK
	printf("stack test begin\n");
	LinkStack Stack;
	ElemType TopData;
	InitStack(&Stack);
	for(int i = 0; i < sizeof(DataBuffer) / sizeof(DataBuffer[0]); i++)
	{
		PushStack(&Stack, DataBuffer[i]);
	}
	while(!StackEmpty(&Stack))
	{
		GetTop(&Stack, &TopData);
		PopStack(&Stack, &data);
		printf("%4d,%4d,%4d\n", data, TopData, LengthStack(&Stack));
	}
	printf("\n");
	printf("stack test end\n");
#endif

	return 0;
}